<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>{$post.title}</title>

  {include file='common/_require'/}
  <link rel="stylesheet" href="/static/css/editor.css">
  <script src="/static/lib/wangEditor/wangEditor.min.js"></script>

  <style>
    .options-item .liked {
      border-color: rgba(255, 165, 0, 0.3);
      background-color: rgba(255, 165, 0, 0.05);
      color: #FFA500;
    }

    .options-item .collected {
      border-color: rgba(255, 165, 0, 0.3);
      background-color: rgba(255, 165, 0, 0.05);
      color: #FFA500;
    }

    .jieda-follow-item {
      display: flex;
      margin-top: 10px;
      margin-left: 15px;
    }

    .jieda-follow-item .follow-avatar {
      width: 40px;
      height: 40px;
      border-radius: 30px;
      background-size: cover;
      background-position: center;
      border: 1px solid #eee;
    }

    .jieda-follow-item .follow-main>div {
      display: inline;
    }

    .jieda-follow-item .follow-info {
      margin-left: 15px;
    }

    .jieda-follow-item .follow-time {
      margin-top: 5px;
      color: #bbb;
    }

    .jieda-follow-item .follow-options {
      display: flex;
      justify-content: flex-start;
      align-items: baseline;

    }

    .jieda-follow-item:hover .follow-admin {
      display: block;
    }

    .jieda-follow-item .follow-admin {
      margin-top: 3px;
      margin-left: 25px;
      display: none;
    }

    .jieda-follow-item .follow-admin span {
      padding-right: 20px;
      color: #999;
      cursor: pointer;
    }

    .comment-content-editor-options {
      margin-top: 5px;
    }

    .yaoqing-container {
      margin-top: 15px;
    }


    .yiyaoqing-list .options-invite {
      display: none;
    }


    .files-item {
      display: flex;
      cursor: pointer;
      align-items: center;
      margin-bottom: 5px;
      line-height: 1.2;
    }

    .files-item .layui-icon {
      font-size: 30px;
    }
  </style>
</head>

<body>

  {include file='common/_header'/}
  {include file='common/_index_header'/}
  <script>$('.index-post-nav-{$post.category_id}').addClass('layui-this')</script>
  <div class="layui-container">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md8 content detail">
        <div class="fly-panel detail-box">
          <h1>{$post.title}</h1>
          <div class="fly-detail-info">
            {neq name='post.is_verify' value='1'}
            <span class="layui-badge">{$post.verify_name}</span>
            {/neq}
            <span class="layui-badge layui-bg-green fly-detail-column">{$post.category.title}</span>

            <!-- <span class="layui-badge" style="background-color: #999;">未结</span> -->
            <!-- <span class="layui-badge" style="background-color: #5FB878;">已结</span> -->
            {eq name='$post.is_top' value='1'}
            <span class="layui-badge layui-bg-black">置顶</span>
            {/eq}
            {eq name='$post.is_good' value='1'}
            <span class="layui-badge layui-bg-red">精帖</span>
            {/eq}

            <div class="fly-admin-box" data-id="123">
              {eq name='$post.user_id' value='$user.id|default=""'}
              <span class="layui-btn layui-btn-xs jie-admin options-delete">删除</span>
              {/eq}

              {eq name='$user.type|default=""' value='1'}
              {eq name='$post.is_top' value='1'}
              <span class="layui-btn layui-btn-xs jie-admin options-top" data-status="0" style="background-color:#ccc;">取消置顶</span>
              {else/}
              <span class="layui-btn layui-btn-xs jie-admin options-top" data-status="1">置顶</span>
              {/eq}
              {eq name='$post.is_good' value='1'}
              <span class="layui-btn layui-btn-xs jie-admin options-good" data-status="0" style="background-color:#ccc;">取消加精</span>
              {else/}
              <span class="layui-btn layui-btn-xs jie-admin options-good" data-status="1">加精</span>
              {/eq}
              {eq name='$post.is_verify' value='1'}
              <span class="layui-btn layui-btn-xs jie-admin options-verify" data-status="0" style="background-color:#ccc;">下架</span>
              <span class="layui-btn layui-btn-xs jie-admin options-verify" data-status="2" style="background-color:#ccc;">撤回审核</span>
              {else/}
              <span class="layui-btn layui-btn-xs jie-admin options-verify" data-status="1">通过审核</span>
              {/eq}
              {/eq}
            </div>
            <span class="fly-list-nums">
              <a href="#comment">
                <i class="iconfont" title="回答">&#xe60c;</i> {$post.comment}
              </a>
              <i class="iconfont" title="人气">&#xe60b;</i> {$post.hits}
            </span>
          </div>
          <div class="detail-about">
            <a class="fly-avatar" href="{:url('User/index',['id'=>$post.user.id])}">
              <img src="{$post.user.avatar_src}" alt="{$post.user.nickname}">
            </a>
            <div class="fly-detail-user">
              <a href="{:url('User/index',['id'=>$post.user.id])}" class="fly-link">
                <cite>{$post.user.nickname}</cite>
                {eq name='post.user.auth_status' value='1'}
                <i class="iconfont icon-renzheng" title="认证信息：{$post.user.auth_content}"></i>
                {/eq}
                <i class="layui-badge fly-badge-vip">{$user.vip.title|default="VIP0"}</i>
              </a>
              <span>{:time_tran($post.create_time)}</span>
            </div>
            <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
              <!-- <span style="padding-right: 10px; color: #FF7200">悬赏：60飞吻</span> -->
              {eq name='$user.id|default=""' value='$post.user_id'}
              <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="{:url('Post/edit',['id'=>$post.id])}">编辑此贴</a></span>
              {/eq}
            </div>
          </div>
          {if !empty($post.jump_to_url) && $post.jump_to_url_status != 0}
          <div class="jump-container">
            <a href="{$post.jump_to_url}" class="layui-btn jump-btn" target="_blank">{$post.jump_to_btn_title|default='立即跳转'}</a>
          </div>
          {/if}
          <div class="detail-body photos main-post-content">
            {$post->content_html|raw}
          </div>

        </div>
        {notempty name='$post.files'}
        <div class="files-container">
          <div class="layui-card">
            <div class="layui-card-header">附件</div>
            <div class="layui-card-body">
              <div class="files-list">

                {volist name='$post.files' id='file'}
                <a class="files-item" href="{:get_source_link($file.save_name)}">
                  <div class="layui-icon layui-icon-file"></div>
                  <div class="info">
                    <p>{$file.title}</p>
                    <p>{$file.size}</p>
                  </div>
                </a>

                {/volist}
              </div>
            </div>
          </div>
        </div>
        {/notempty}
        <div class="options-container">

          <div class="detail-options">
            <div class="options-item">
              <i class="startsns-font startsns-icon-diancai1-copy options-zan {eq name='$post.is_like' value='1'}liked{/eq}"></i>
              <div class="info">
                <p class="title">点赞</p>
                <p class="nums">{$post.zan}</p>
              </div>
            </div>
            <div class="options-item">
              <i class="startsns-font startsns-icon-shoucang1 options-collect {eq name='$post.is_collect' value='1'}liked{/eq}"></i>
              <div class="info">
                <p class="title">收藏</p>
                <p class="nums">{$post.collect}</p>
              </div>
            </div>
            <div class="options-item">
              <i class="startsns-font startsns-icon-pinglun options-comment" style="color: #3E9CBB;border-color: rgba(62,156,187,0.3);background-color: rgba(62,156,187,0.05);"></i>
              <div class="info">
                <p class="title">评论</p>
                <p class="nums">{$post.comment}</p>
              </div>
            </div>
            {if !empty($post.user.income_qrcode_wechat) || !empty($post.user.income_qrcode_alipay) }
            <div class="options-item ">
              <i class="startsns-font startsns-icon-dashang3 comment-reward" data-wechat="{$post.user->getData('income_qrcode_wechat')}" data-alipay="{$post.user->getData('income_qrcode_alipay')}" style="border-color: rgba(217,44,47,0.3);background-color: rgba(217,44,47,0.05);color: #D92C2F;"></i>
              <div class="info">
                <p class="title">打赏</p>
              </div>
            </div>
            {/if}
            <div class="options-item">
              <i class="startsns-font startsns-icon-yaoqing options-yaoqing"></i>
              <div class="info">
                <p class="title">邀请</p>
              </div>
            </div>
          </div>
          <div class="yaoqing-container" style="display: none;">
            <div class="yaoqing-header">
              <form action="" class="layui-form" lay-filter="yaoqing-search">
                <div class="layui-form-item">

                  <div class="layui-form-label">邀请</div>
                  <div class="layui-input-block">

                    <div class="layui-input-inline">

                      <input type="text" name="keywords" class="layui-input" placeholder="请输入昵称">

                    </div>
                    <div class="layui-input-inline" style="width: 285px;">

                      <input type="radio" name="search_type" value="0" title="全部" id="" checked>
                      <input type="radio" name="search_type" value="1" title="已认证" id="">
                      <input type="radio" name="search_type" value="2" title="我的关注" id="">

                    </div>
                    <div class="layui-input-inline">
                      <button class="layui-btn" type="submit" lay-submit lay-filter="yaoqing">搜索</button>
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-form-label">已邀请</div>
                  <div class="yiyaoqing-list user-tab-list">
                    {volist name='post.invited' id='vo'}
                    <div class="user-item user-item-{$vo.user.id}">
                      <a class="user-avatar" href="{:url('User/index',['id'=>$vo.user.id])}" style="background-image: url('{$vo.user.avatar_src}');">
                      </a>
                      <div class="user-info">
                        <a href="{:url('User/index',['id'=>$vo.user.id])}" class="fly-link">
                          <cite>{$vo.user.nickname}</cite>
                          {eq name='vo.user.auth_status' value='1'}
                          <i class="iconfont icon-renzheng" title="认证信息：{$vo.user.auth_content}"></i>
                          {/eq}
                          <i class="layui-badge fly-badge-vip">{$vo.user.vip.title|default=''}</i>
                        </a>
                        <div class="time">{:time_tran($vo.user.create_time)}</div>
                        <div>
                          <div class="layui-btn layui-btn-xs options-invite">邀请</div>
                        </div>
                      </div>
                    </div>
                    {/volist}

                    {empty name='$post.invited'}
                    <div class="layui-word-aux yiyaoqing-tips">还没有邀请任何人</div>
                    {else /}
                    {/empty}
                  </div>
                  <hr>
                </div>
              </form>

            </div>

            <div class="yaoqing-body" style="display: none;">
              <div class="yaoqing-list user-tab-list"></div>
              <div class="yaoqing-tips" style="text-align: center;margin-top: 15px;cursor: pointer;">加载更多</div>
            </div>
          </div>
          <div class="comment-container" style="display: none;">

            <div id="comment-editor" class="main-post-content">

            </div>
            <div class="comment-submit" style="margin-top: 15px;">
              <div class="layui-btn send-comment">
                发表评论
              </div>
            </div>
          </div>
        </div>
        <div class="fly-panel detail-box" id="flyReply">
          <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
            <legend>回帖</legend>
          </fieldset>

          <ul class="jieda" id="jieda">
            {volist name='post.comments' id='comment'}

            <li data-comment-id="{$comment.id}" data-user-id="{$comment.user.id}" class="jieda-daan comment-item">
              <a name="item-{$comment.id}"></a>
              <div class="detail-about detail-about-reply">
                <a href="{$comment.user.index_url}" class="fly-avatar" href="">
                  <img src="{$comment.user.avatar_src}" alt=" ">
                </a>
                <div class="fly-detail-user">
                  <a href="{$comment.user.index_url}" class="fly-link">
                    <cite>{$comment.user.nickname}</cite>
                    {eq name='comment.user.auth_status' value='1'}
                    <i class="iconfont icon-renzheng" title="认证信息：{$comment.user.auth_content}"></i>
                    {/eq}

                    <i class="layui-badge fly-badge-vip">{$user.vip.title|default="VIP0"}</i>
                  </a>
                  {eq name='$post.user.id' value='$comment.user.id'}
                  <span>(楼主)</span>
                  {/eq}
                  {eq name='comment.user.type' value='1'}
                  <span style="color:#5FB878">(管理员)</span>
                  {/eq}
                  {eq name='comment.user.status' value='1'}
                  <span style="color:#999">（该号已被封）</span>
                  {/eq}

                </div>

                <div class="detail-hits">
                  <span>{:time_tran($comment.create_time)}</span>
                </div>

                <i class="iconfont icon-caina" {eq name='comment.is_good' value='0' } style="display: none;" {/eq} title="最佳答案"></i>

              </div>
              <div class="detail-body jieda-body comment-content">
                <blockquote class="layui-elem-quote comment-hidden-tips" {eq name='$comment.status' value='0' }style="display: none;" {/eq}>评论已下架,仅作者和管理员可见</blockquote>

                {if $comment.status == 0 || ( !empty($user) && ( $user.id == $post.user.id || $user.id == $comment.user.id || $user.type == 1 )) }
                <div class="comment-content-main main-post-content">{$comment.content_html|raw}</div>
                {/if}
                <div class="comment-content-editor" style="display: none;">
                  <div class="comment-content-editor-main">

                  </div>
                  <div class="comment-content-editor-options">
                    <div class="layui-btn comment-save">保存</div>
                    <div class="layui-btn comment-cancle">取消</div>
                  </div>
                </div>

              </div>
              <div class="jieda-reply">
                <span class="jieda-zan comment-zan {eq name='$comment.attitude_status' value='1'}zanok{/eq}">
                  <i class="layui-icon layui-icon-praise"></i>
                  <em>{$comment.zan}</em>
                </span>
                <span class="jieda-zan comment-tread {eq name='$comment.attitude_status' value='2'}zanok{/eq}">
                  <i class="layui-icon layui-icon-tread"></i>
                  <em>{$comment.tread}</em>
                </span>
                <span type="reply" class="comment-follow">
                  <i class="layui-icon layui-icon-dialogue"></i>
                  回复
                </span>
                <div class="jieda-admin">
                  {if !empty($comment.user->getData('income_qrcode_wechat')) || !empty($comment.user->getData('income_qrcode_alipay')) }
                  <span class="comment-reward" data-wechat="{$comment.user->getData('income_qrcode_wechat')}" data-alipay="{$comment.user->getData('income_qrcode_alipay')}">打赏</span>
                  {/if}
                  {if !empty($user) }
                  {if $user.type == 1 && $user.id != $post.user.id && $user.id != $comment.user.id}
                  <!-- 如果当前用户是管理员 -->

                  <span class="comment-manage-show {eq name='$comment.status' value='0'}u-hidden{/eq}" title="以管理员身份">上架</span>
                  <span class="comment-manage-hide {eq name='$comment.status' value='1'}u-hidden{/eq}" title="以管理员身份">下架</span>
                  <span class="comment-manage-delete" title="以管理员身份">删除</span>

                  {/if}
                  {if $post.user.id == $user.id && $user.id != $comment.user.id }
                  <!-- 如果当前用户是是作者 -->
                  <span class="comment-author-show {eq name='$comment.status' value='0'}u-hidden{/eq}" title="以文章作者身份">上架</span>
                  <span class="comment-author-hide {eq name='$comment.status' value='1'}u-hidden{/eq}" title="以文章作者身份">下架</span>
                  <span class="comment-author-delete" title="以文章作者身份">删除</span>

                  {/if}
                  {eq name='comment.user.id' value='$user.id'}
                  <span class="comment-edit" title="以评论作者身份">编辑</span>
                  <span class="comment-delete" title="以评论作者身份">删除</span>
                  {/eq}
                  {eq name='user.id' value='$post.user.id'}
                  {eq name='comment.is_good' value='1'}
                  <span class="jieda-accept comment-set-good" data-status="0">撤销采纳</span>
                  {else/}
                  <span class="jieda-accept comment-set-good" data-status="1">采纳</span>
                  {/eq}

                  {/eq}
                  {/if}
                </div>
              </div>
              <div class="jieda-follow">
                <div class="jieda-follow-body">
                  {volist name='comment.follows' id='follow'}
                  <div class="jieda-follow-item follow-item" data-id="{$follow.id}" data-user-id="{$follow.user.id}">
                    <a href="{$follow.user.index_url}" class="follow-avatar" style="background-image: url('{$follow.user.avatar_src}');">
                    </a>
                    <div class="follow-info">
                      <div class="follow-main">
                        <a href="{$follow.user.index_url}" class="fly-link follow-nickname">
                          {$follow.user.nickname}
                          {eq name='follow.user.auth_status' value='1'}
                          <i class="iconfont icon-renzheng" title="认证信息：{$follow.user.auth_content}"></i>
                          {/eq}
                        </a>
                        <span>:
                          <span class="comment-hidden-tips" {eq name='$follow.status' value='0' }style="display: none;" {/eq}>(回复已下架,仅作者和管理员可见)</span>
                        </span>
                        {if $follow.status == 0 || $user.id == $post.user.id || $user.id == $comment.user.id || $user.id == $follow.user.id || $user.type == 1 }
                        <div class="follow-content">{$follow.content}</div>
                        {/if}
                      </div>
                      <div class="follow-options">
                        <div class="follow-time">
                          {:time_tran($follow->create_time)}
                        </div>
                        <div class="follow-admin">
                          <span class="comment-follow">回复</span>
                          {if !empty($follow.user->getData('income_qrcode_wechat')) || !empty($follow.user->getData('income_qrcode_alipay')) }
                          <span class="comment-reward" data-wechat="{$follow.user->getData('income_qrcode_wechat')}" data-alipay="{$follow.user->getData('income_qrcode_alipay')}">打赏</span>
                          {/if}
                          {if !empty($user) }
                            {if $user.type == 1 && $user.id != $post.user.id && $user.id != $follow.user.id && $user.id != $comment.user.id}
                            <!-- 如果当前用户是管理员 -->

                            <span class="follow-manage-show {eq name='$follow.status' value='0'}u-hidden{/eq}" title="以管理员身份">上架</span>
                            <span class="follow-manage-hide {eq name='$follow.status' value='1'}u-hidden{/eq}" title="以管理员身份">下架</span>
                            <span class="follow-manage-delete" title="以管理员身份">删除</span>

                            {/if}
                            {if $post.user.id == $user.id && $user.id != $follow.user.id && $user.id != $comment.user.id}
                            <!-- 如果当前用户是是文章作者 -->
                            <span class="follow-author-show {eq name='$follow.status' value='0'}u-hidden{/eq}" title="以文章作者身份">上架</span>
                            <span class="follow-author-hide {eq name='$follow.status' value='1'}u-hidden{/eq}" title="以文章作者身份">下架</span>
                            <span class="follow-author-delete" title="以文章作者身份">删除</span>
                            {/if}
                            {if $user.id != $follow.user.id && $user.id == $comment.user.id}
                            <!-- 如果当前用户是评论作者 -->
                            <span class="follow-comment-author-show {eq name='$follow.status' value='0'}u-hidden{/eq}" title="以评论作者身份">上架</span>
                            <span class="follow-comment-author-hide {eq name='$follow.status' value='1'}u-hidden{/eq}" title="以评论作者身份">下架</span>
                            <span class="follow-comment-author-delete" title="以评论作者身份">删除</span>
                            {/if}
                            {eq name='follow.user.id' value='$user.id'}
                            <span class="follow-edit" title="以评论回复作者身份">编辑</span>
                            <span class="follow-delete" title="以评论回复作者身份">删除</span>
                            {/eq}
                          {/if}

                        </div>
                      </div>
                    </div>
                  </div>
                  {/volist}
                </div>
              </div>

            </li>
            {/volist}


            {empty name='$post.comments'}

            <li class="fly-none">消灭零回复</li>

            {/empty}

            <!-- 无数据时 -->
          </ul>


        </div>
      </div>
      <div class="layui-col-md4">
        <dl class="fly-panel fly-list-one">
          <dt class="fly-panel-title">本周热议</dt>
          {volist name='list_post' id='vo'}
          <dd>
            <a href="{$vo.read_url}">{$vo.title}</a>
            <span><i class="iconfont icon-pinglun1"></i> {$vo.comment}</span>
          </dd>
          {/volist}

          <!-- 无数据时 -->
          <!--
          <div class="fly-none">没有相关数据</div>
          -->
        </dl>
        {notempty name='\app\model\Nav::getListIndexNav("post_read_ad")'}
        <div class="fly-panel">
          <div class="fly-panel-title">
            广告赞助
          </div>
          <div class="fly-panel-main">
            {volist name='\app\model\Nav::getListIndexNav("post_read_ad")' id='nav'}
            {empty name='$nav->getData("img")'}
            <a href="{$nav.value}" target="{$nav.target}" class="fly-zanzhu" style="background-color: #66CCFF ;">{$nav.title}</a>
            {else /}
            <a href="{$nav.value}" target="{$nav.target}" class="fly-zanzhu" style="background-image: url('{$nav.img}');background-size: cover;background-position: center;">{$nav.title}</a>
            {/empty}
            {/volist}
          </div>
        </div>
        {/notempty}


      </div>
    </div>
  </div>
  {include file='common/_footer'/}

  <script>

    var commentEditorMenus = [
      'bold',
      'underline',
      'strikeThrough',
      'link',
      'list',
      'image',
      'video',
      'table',
      'code',
    ]

    $('.comment-delete').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.confirm('确定要删除吗?', function (index) {
        $.post('{:url("PostComment/delete")}', {
          id: $(parent).data('comment-id')
        }, function () {
          layer.msg('删除成功')
          $(parent).remove();
        })
      })
    })

    // 文章作者审核评论

    $('.comment-author-delete').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.prompt({
        formType: 2,
        title: "以文章作者名义删除",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostComment/delete")}', {
          id: $(parent).data('comment-id')
        }, function () {
          layer.msg('删除成功')
          layer.close(index)
          $(parent).remove();
          sendRecord({
            type: 'comment_deleted_by_post_author',
            target_id: $(parent).data('comment-id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.comment-author-hide').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.prompt({
        formType: 2,
        title: "以文章作者名义下架",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostComment/update")}', {
          id: $(parent).data('comment-id'),
          status: 1
        }, function () {
          layer.msg('下架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').show();
          $(item).hide()
          $(parent).find('.comment-author-show').show()
          sendRecord({
            type: 'comment_hide_by_post_author',
            target_id: $(parent).data('comment-id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.comment-author-show').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.prompt({
        formType: 2,
        title: "以文章作者名义上架",
        value: '评论审核通过',
      }, function (value, index) {
        $.post('{:url("PostComment/update")}', {
          id: $(parent).data('comment-id'),
          status: 0
        }, function () {
          layer.msg('上架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').hide();
          $(item).hide()
          $(parent).find('.comment-author-hide').show()
          sendRecord({
            type: 'comment_show_by_post_author',
            target_id: $(parent).data('comment-id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })

    // 管理员审核评论

    $('.comment-manage-delete').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.prompt({
        formType: 2,
        title: "以管理员名义删除",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostComment/delete")}', {
          id: $(parent).data('comment-id')
        }, function () {
          layer.msg('删除成功')
          layer.close(index)
          $(parent).remove();
          sendRecord({
            type: 'comment_deleted_by_manage',
            target_id: $(parent).data('comment-id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.comment-manage-hide').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.prompt({
        formType: 2,
        title: "以管理员名义下架",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostComment/update")}', {
          id: $(parent).data('comment-id'),
          status: 1
        }, function () {
          layer.msg('下架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').show();
          $(item).hide()
          $(parent).find('.comment-manage-show').show()
          sendRecord({
            type: 'comment_hide_by_post_manage',
            target_id: $(parent).data('comment-id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.comment-manage-show').click(function () {
      var item = this;
      var parent = $(item).closest('.comment-item')
      layer.prompt({
        formType: 2,
        title: "以管理员名义上架",
        value: '评论审核通过',
      }, function (value, index) {
        $.post('{:url("PostComment/update")}', {
          id: $(parent).data('comment-id'),
          status: 0
        }, function () {
          layer.msg('上架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').hide();
          $(item).hide()
          $(parent).find('.comment-manage-hide').show()
          sendRecord({
            type: 'comment_show_by_manage',
            target_id: $(parent).data('comment-id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })


    // 管理员审核评论回复

    $('.follow-manage-delete').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以管理员名义删除",
        value: '评论回复违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/delete")}', {
          id: $(parent).data('id')
        }, function () {
          layer.msg('删除成功')
          layer.close(index)
          $(parent).remove();
          sendRecord({
            type: 'comment_follow_deleted_by_manage',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.follow-manage-hide').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以管理员名义下架",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          status: 1
        }, function () {
          layer.msg('下架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').show();
          $(item).hide()
          $(parent).find('.follow-manage-show').show()
          sendRecord({
            type: 'comment_follow_hide_by_manage',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.follow-manage-show').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以管理员名义上架",
        value: '评论审核通过',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          status: 0
        }, function () {
          layer.msg('上架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').hide();
          $(item).hide()
          $(parent).find('.follow-manage-hide').show()
          sendRecord({
            type: 'comment_follow_show_by_manage',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    // 文章作者审核评论回复

    $('.follow-author-delete').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以文章作者名义删除",
        value: '评论回复违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/delete")}', {
          id: $(parent).data('id')
        }, function () {
          layer.msg('删除成功')
          layer.close(index)
          $(parent).remove();
          sendRecord({
            type: 'comment_follow_deleted_by_post_author',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.follow-author-hide').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以文章作者名义下架",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          status: 1
        }, function () {
          layer.msg('下架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').show();
          $(item).hide()
          $(parent).find('.follow-author-show').show()
          sendRecord({
            type: 'comment_follow_hide_by_post_author',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.follow-author-show').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以文章作者名义上架",
        value: '评论审核通过',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          status: 0
        }, function () {
          layer.msg('上架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').hide();
          $(item).hide()
          $(parent).find('.follow-author-hide').show()
          sendRecord({
            type: 'comment_follow_show_by_post_author',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    // 评论作者审核评论回复

    $('.follow-comment-author-delete').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以评论作者名义删除",
        value: '评论回复违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/delete")}', {
          id: $(parent).data('id')
        }, function () {
          layer.msg('删除成功')
          layer.close(index)
          $(parent).remove();
          sendRecord({
            type: 'comment_follow_deleted_by_comment_author',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.follow-comment-author-hide').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以评论作者名义下架",
        value: '评论违反社区规则',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          status: 1
        }, function () {
          layer.msg('下架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').show();
          $(item).hide()
          $(parent).find('.follow-comment-author-show').show()
          sendRecord({
            type: 'comment_follow_hide_by_comment_author',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })
    $('.follow-comment-author-show').click(function () {
      var item = this;
      var parent = $(item).closest('.follow-item')
      layer.prompt({
        formType: 2,
        title: "以评论作者名义上架",
        value: '评论审核通过',
      }, function (value, index) {
        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          status: 0
        }, function () {
          layer.msg('上架成功')
          layer.close(index)
          $(parent).find('.comment-hidden-tips').hide();
          $(item).hide()
          $(parent).find('.follow-comment-author-hide').show()
          sendRecord({
            type: 'comment_follow_show_by_comment_author',
            target_id: $(parent).data('id'),
            from_user_id: '{$user.id|default=""}',
            target_user_id: $(parent).data('user-id'),
            content: value
          })
        })
      })
    })

    $('.comment-set-good').click(function () {
      var item = $(this);
      var parent = $(parent)

      if ($(parent).find('.icon-caina').is(':visible')) {
        var newStatus = 0
        $(parent).find('.icon-caina').hide()
        $(parent).find('.comment-set-good').text('采纳')
      } else {
        var newStatus = 1
        $(parent).find('.icon-caina').show()
        $(parent).find('.comment-set-good').text('撤销采纳')
      }
      $.post('{:url("PostComment/update")}', {
        id: $(parent).data('comment-id'),
        is_good: newStatus
      }, function () {
        layer.msg('操作成功')


      })
    })

    $('.comment-edit').click(function () {
      var item = $(this);
      var parent = $(parent)

      $(parent).find('.comment-content-main').hide()
      $(parent).find('.comment-content-editor').show();
      var commentEditor = initWangEditor({
        editorElem: $(parent).find('.comment-content-editor-main')[0],
        height: 'auto',
        menus: commentEditorMenus
      })

      commentEditor.txt.html($(parent).find('.comment-content-main').html())

      $(parent).find('.comment-save').click(function () {
        $.post('{:url("PostComment/update")}', {
          id: $(parent).data('comment-id'),
          content_html: commentEditor.txt.html()
        }, function () {
          layer.msg('保存成功')
          $(parent).find('.comment-content-main').html(commentEditor.txt.html())
          $(parent).find('.comment-content-main').show()
          $(parent).find('.comment-content-editor').hide();
          commentEditor.destroy()
          $(parent).find('.comment-save').unbind()

        })
      })
      $(parent).find('.comment-cancle').click(function () {
        $(parent).find('.comment-content-main').show()
        $(parent).find('.comment-content-editor').hide();
        commentEditor.destroy()
        $(parent).find('.comment-save').unbind()
      })

    })

    $('.follow-delete').click(function () {
      var item = $(this)
      var parent = $(item).parents('.follow-item')
      layer.confirm('确定要删除吗?', function (index) {
        $.post('{:url("PostCommentFollow/delete")}', {
          id: $(parent).data('id')
        }, function () {
          layer.msg('删除成功')
          $(parent).remove();
        })
      })
    })

    $('.follow-edit').click(function () {
      var item = $(this)
      var parent = $(item).parents('.follow-item')

      layer.prompt({
        formType: 2,
        title: "请输入评论",
        value: $(parent).find('.follow-content').text(),
        area: ['400px', '150px'] //自定义文本域宽高
      }, function (value, index) {

        $.post('{:url("PostCommentFollow/update")}', {
          id: $(parent).data('id'),
          content: value
        }, function (result) {
          if (result.code == 0) {
            layer.msg('提交成功')
            $(parent).find('.follow-content').text(value)

            layer.close(index)
          } else {
            layer.msg(result.msg)
          }
        })

      })

    })

    $('.comment-reward').click(function () {
      var item = this;
      var imgList = [];
      var wechat = $(item).data('wechat')

      if (wechat.length > 0) {
        imgList.push({
          "alt": "微信支付",
          "pid": 1, //图片id
          "src": "{:get_source_domain()}/" + wechat, //原图地址
        })
      }
      var alipay = $(item).data('alipay')

      if (alipay.length > 0) {
        imgList.push({
          "alt": "支付宝支付",
          "pid": 2, //图片id
          "src": "{:get_source_domain()}/" + alipay, //原图地址
        })
      }

      layer.photos({
        photos: {
          "title": "", //相册标题
          "id": 123, //相册id
          "start": 0, //初始显示的图片序号，默认0
          "data": imgList
        }
        , anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
      });
    })

    $.get('{:url("incHits",["id"=>$post.id])}')
    $('.options-delete').click(function () {

      layer.confirm('确定要删除吗?', function (index) {

        $.post('{:url("delete")}', {
          id: '{$post.id}'
        }, function (result) {
          layer.msg('删除成功')
          setTimeout(() => {
            location.href = '/'
          }, 1200);
        })
      })
    })
    $('.options-top').click(function () {
      var status = $(this).data('status')

      $.post('{:url("update")}', {
        id: '{$post.id}',
        is_top: status
      }, function (result) {
        layer.msg('操作成功')
        setTimeout(() => {
          location.reload()
        }, 1200);
      })
    })
    $('.options-good').click(function () {
      var status = $(this).data('status')

      $.post('{:url("update")}', {
        id: '{$post.id}',
        is_good: status
      }, function (result) {
        layer.msg('操作成功')
        setTimeout(() => {
          location.reload()
        }, 1200);
      })
    })
    $('.options-verify').click(function () {
      var status = $(this).data('status')

      $.post('{:url("update")}', {
        id: '{$post.id}',
        is_verify: status
      }, function (result) {
        layer.msg('操作成功')
        setTimeout(() => {
          location.reload()
        }, 1200);
      })
    })
    $('.options-zan').click(function () {
      var status = 1;
      var item = this
      if ($(this).hasClass('liked')) {
        status = 0
      }
      $.post('{:url("optionLike")}', {
        id: '{$post.id}',
        status: status
      }, function (result) {
        if (result.code == 0) {
          layer.msg('操作成功')
          if (status == 1) {
            $(item).addClass('liked')
            $(item).siblings('.info').find('.nums').text(parseInt($(item).siblings('.info').find('.nums').text()) + 1)
          } else {
            $(item).removeClass('liked')
            $(item).siblings('.info').find('.nums').text(parseInt($(item).siblings('.info').find('.nums').text()) - 1)
          }
        } else {
          layer.msg(result.msg)
        }

      })
    })
    $('.options-collect').click(function () {
      var status = 1;
      var item = this
      if ($(this).hasClass('liked')) {
        status = 0
      }
      $.post('{:url("optionCollect")}', {
        id: '{$post.id}',
        status: status
      }, function (result) {
        if (result.code == 0) {
          layer.msg('操作成功')

          if (status == 1) {
            $(item).addClass('liked')
            $(item).siblings('.info').find('.nums').text(parseInt($(item).siblings('.info').find('.nums').text()) + 1)
          } else {
            $(item).removeClass('liked')
            $(item).siblings('.info').find('.nums').text(parseInt($(item).siblings('.info').find('.nums').text()) - 1)
          }

        } else {
          layer.msg(result.msg)
        }

      })
    })

    $('.comment-follow').click(function () {
      var item = this;

      var parent = $(item).closest('.comment-item');

      layer.prompt({
        formType: 2,
        title: "请输入评论",
        area: ['400px', '150px'] //自定义文本域宽高
      }, function (value, index) {

        $.post('{:url("PostCommentFollow/save")}', {
          post_id: '{$post.id}',
          comment_id: $(parent).data('comment-id'),
          content: value
        }, function (result) {
          if (result.code == 0) {
            layer.msg('提交成功')
            setTimeout(() => {
              location.reload();
            }, 1200);
          } else {
            layer.msg(result.msg)
          }
        })

      })

    })

    $('.options-comment').click(function () {

      var user_id = parseInt('{:session("user_id")}');

      if (!isNaN(user_id) && user_id > 0) {

        if ($('.comment-container').is(':visible')) {
          $('.comment-container').hide()
        } else {
          $('.comment-container').show()
        }
      } else {
        layer.msg("请前往登录")
      }
    })


    $('.options-yaoqing').click(function () {
      var user_id = parseInt('{:session("user_id")}');

      if ($('.yaoqing-container').is(':visible')) {
        $('.yaoqing-container').hide()
      } else {
        $('.yaoqing-container').show()
      }

    })


    $('.comment-zan').click(function () {
      var user_id = parseInt('{:session("user_id")}');

      if (isNaN(user_id) || user_id == 0) {
        layer.msg('请前往登录')
        return false
      }
      var item = this;
      var parent = $(item).closest('.comment-item')
      var status = 1
      if ($(item).hasClass('zanok')) {
        $(item).removeClass('zanok')
        status = 0
      } else {
        $(item).addClass('zanok')
        $(parent).find('.comment-tread').removeClass('zanok')
      }

      $.post('{:url("optionCommentAttitude")}', {
        comment_id: $(parent).data('id'),
        attitude_status: status
      }, function (result) {
        if (result.code == 0) {
          layer.msg('操作成功')
          $(parent).find('.comment-zan em').text(result.data.zan)
          $(parent).find('.comment-tread em').text(result.data.tread)
        } else {
          layer.msg(result.msg)
        }
      })

    })
    $('.comment-tread').click(function () {
      var user_id = parseInt('{:session("user_id")}');
      var parent = $(item).closest('.comment-item')
      if (isNaN(user_id) || user_id == 0) {
        layer.msg('请前往登录')
        return false
      }
      var item = this;
      var status = 2
      if ($(item).hasClass('zanok')) {
        $(item).removeClass('zanok')
        status = 0
      } else {
        $(item).addClass('zanok')
        $(parent).find('.comment-zan').removeClass('zanok')
      }

      $.post('{:url("optionCommentAttitude")}', {
        comment_id: $(parent).data('id'),
        attitude_status: status
      }, function (result) {
        if (result.code == 0) {
          layer.msg('操作成功')
          $(parent).find('.comment-zan em').text(result.data.zan)
          $(parent).find('.comment-tread em').text(result.data.tread)
        } else {
          layer.msg(result.msg)
        }
      })

    })

    $('.yaoqing-list').on('click', '.options-invite', function () {
      var item = this;
      var parentItem = $(item).parents('.user-item')
      $.post('{:url("optionInvite")}', {
        user_id: parentItem.data('id'),
        post_id: '{$post.id}',

      }, function (result) {
        if (result.code == 0) {
          layer.msg('邀请成功')

          if ($('.user-item-' + parentItem.data('id')).length == 0) {
            parentItem.appendTo('.yiyaoqing-list')
            parentItem.addClass('user-item-' + parentItem.data('id'))
          } else {
            parentItem.hide()

          }

          $('.yiyaoqing-tips').hide()

        } else {
          layer.msg(result.msg)
        }
      })
    })

    layui.use(['form', 'upload'], function () {

      var upload = layui.upload
      var form = layui.form

      form.on('submit(yaoqing)', function (data) {
        window.yaoqingPage = 1
        $('.yaoqing-tips').text('加载更多')
        $('.yaoqing-list').children().remove()
        $('.yaoqing-body').show();
        loadYaoqingList()
        return false
      })

      $('.yaoqing-tips').click(function () {
        loadYaoqingList()
      })

      function loadYaoqingList() {
        var data = form.val('yaoqing-search')
        data.page = window.yaoqingPage
        $.get('{:url("Post/yaoqing")}', data, function (result) {
          window.yaoqingPage++
          if (result.length > 0) {

            $('.yaoqing-list').append(result)
          } else {
            $('.yaoqing-tips').text('加载完了')
          }

        })

      }

      var initEditor = initWangEditor({
        editorElem: '#comment-editor',
        height: 'auto',
        menus: commentEditorMenus
      })

      $('.send-comment').click(function () {
        var formData = {};
        formData.post_id = '{$post.id}'
        formData.content_html = initEditor.txt.html()

        console.log(formData);

        $.post('{:url("PostComment/save")}', formData, function (result) {
          if (result.code == 0) {

            layer.msg('保存成功')
            setTimeout(() => {
              location.reload();
            }, 1200);
          } else {
            layer.msg(result.msg)
          }
        })
      })


    })

  </script>
</body>

</html>